<template>
    <div class="default-main2 ba-table-box" style="margin-top: 10px;" v-loading="load">
        <el-card style="width: 48.5%;float: left;margin-left: 1%;height:580px;">
            <template #header>
            <div class="card-header">
                <h3>商品销量前10排行</h3>
            </div>
            </template>
            <table class="table">
                    <tr>
                         <th width="100" class="tc">排行</th>
                         <th>商品</th>
                         <th class="tc">销量</th>
                    </tr>
                    <tr v-for="(item,index) in data.rank_goods_sellnum">
                         <td class="tc"><span :class="'yuan yuan'+index">{{ index+1 }}</span></td>
                         <td style="text-align: left;">{{ item.title }}</td>
                         <td class="tc">{{ item.sell_num }}</td>
                    </tr>
            </table>
            
        </el-card>

        <el-card style="width: 48.5%;float: left;margin-left: 1%;height:580px;">
            <template #header>
            <div class="card-header">
                <h3>用户消费前10排行</h3>
            </div>
            </template>
            <table class="table">
                    <tr>
                         <th width="100" class="tc">排行</th>
                         <th class="tc">用户昵称</th>
                         <th class="tc">销量金额</th>
                    </tr>
                    <tr v-for="(item,index) in data.rank_user_ordermoney">
                         <td class="tc">
                                <span :class="'yuan yuan'+index">{{ index+1 }}</span>
                         </td>
                         <td>{{ item.nickname }}</td>
                         <td>{{ item.total_money }}</td>
                    </tr>
            </table>
            
        </el-card>


        <!-- <el-card style="width: 48.5%;float: left;margin-left: 1%;margin-top: 15px;height:580px;">
            <template #header>
            <div class="card-header">
                <span>商品销量前10排行</span>
            </div>
            </template>
            <table class="table">
                    <tr>
                         <th width="100" class="tc">排行</th>
                         <th>商品</th>
                         <th>销量</th>
                    </tr>
                    <tr v-for="(item,index) in data">
                         <td class="tc"><span :class="'yuan yuan'+index">{{ index+1 }}</span></td>
                         <td>{{ item.title }}</td>
                         <td>{{ item.sell_num }}</td>
                    </tr>
            </table>
            
        </el-card>

        <el-card style="width: 48.5%;float: left;margin-left: 1%;margin-top: 15px;height:580px;">
            <template #header>
            <div class="card-header">
                <span>商品销售额前10排行</span>
            </div>
            </template>
            <table class="table">
                    <tr>
                         <th width="100" class="tc">排行</th>
                         <th>商品</th>
                         <th>销量</th>
                    </tr>
                    <tr v-for="(item,index) in data">
                         <td class="tc"><span :class="'yuan yuan'+index">{{ index+1 }}</span></td>
                         <td>{{ item.title }}</td>
                         <td>{{ item.sell_num }}</td>
                    </tr>
            </table>
            
        </el-card> -->




    </div>
</template>

<script setup lang="ts">
import { ref, provide,onMounted} from 'vue'
import baTableClass from '/@/utils/baTable'
import Table from '/@/components/table/index.vue'
import TableHeader from '/@/components/table/header/index.vue'
import { defaultOptButtons } from '/@/components/table'
import { baTableApi } from '/@/api/common'
import { useI18n } from 'vue-i18n'
import createAxios from "/@/utils/axios";
defineOptions({
    name: 'statics/rank',
})

const { t } = useI18n()
const data = ref([])
const load = ref(false)

const getList = () => {
    load.value = true
    return createAxios({
        url: '/admin/statics.Rank/index',
        method: 'GET',
        params:{}
    }).then(res => {
        data.value = res.data.list
        load.value = false
    }).catch(err => {
        load.value = false
    })
}
onMounted(() => {
    getList()
})


</script>

<style scoped lang="scss">
.table{
     border:1px solid #eee;
     width: 100%;
     border-collapse: collapse; /* 合并边框，消除间隙 */
 
}
.table th{
    border: 1px solid #eee;
    padding: 10px;
    text-align: left;
}
.table td{
    border: 1px solid #eee;
    padding: 10px;
}
.table tr .bg{
    background-color: #f5f7fa;
    font-weight: bold;
    text-align: justify;
}
.table tr .tc{
    text-align: center;
}
.table tr .yuan{
    background-color: #ccc;
    width: 22px ;
    height: 22px;
    display: block;
    text-align: center;
    border-radius: 100%;
    color:#fff;
    font-size: 11px;
    line-height: 22px;
    margin: 0 auto;
}
.table tr .yuan0{
    background-color: #99CC33;
}
.table tr .yuan1{
    background-color: #FF6666;
}
.table tr .yuan2{
    background-color: #FF9900;
}
</style>
